package com.jay.base.ui

import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.arouter.launcher.ARouter
import com.jay.media.kit.LogHelper

/**
 * @author xuzhou4
 * @date 2022/2/17
 */
abstract class BaseActivity : AppCompatActivity(), BaseUI {

    protected var TAG = LogHelper.makeLogTag(this::class.java)

    override fun rootView(container: ViewGroup?): View? = null

    override fun layoutId(): Int = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val rootView = rootView(null)
        when {
            rootView != null -> {
                setContentView(rootView)
            }
            layoutId() > 0 -> {
                setContentView(layoutId())
            }
            else -> {
                throw IllegalArgumentException("please call setContentView first !!!")
            }
        }
        ARouter.getInstance().inject(this)
        initView(findViewById(android.R.id.content))
        initData()
    }

    override fun initParams() {

    }

    override fun initView(view: View) {

    }

    override fun initData() {

    }

    fun setToolbarTitle(t: CharSequence?) {
        supportActionBar?.title = t
    }
}